const fs = require('fs');
let mobile = "1133123456789"
console.log(1);
// 异步的方法,不会阻碍同步的执行
// 异步为了保障顺序,会发生回调地狱现象

let fn2 = ( name ) => {
  fs.readFile("./chp07-02promise.txt","utf-8",(err,data) => {
    let arr2 = data.split("\r\n")
    let ren_arr2 =  arr2[0].split(":")
    if (ren_arr2[0]===name) {   
      console.log(ren_arr2[1]);
    }
  })
}

let fn2Err = () => {
  console.log("出错了");
}

fs.readFile("./chp07-01promise11.txt","utf-8",(err,data) => {
  if (err) {
    // fn02Err()
    return
  }
  let arr = data.split("\r\n")
  let ren_arr =  arr[0].split(":")
  if (ren_arr[0]===mobile) {    
    let name = ren_arr[1];
    // fn2(name)    
  }
})

console.log(2);